import 'package:blog/screens/search_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';

import '../../../constants.dart';
import '../../../routes.dart';
import 'sidebar_container.dart';

class Search extends StatefulWidget {
  const Search({
    Key? key,
  }) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _SearchState();
  }
}

class _SearchState extends State<Search> {
  String searchText = '';

  @override
  Widget build(BuildContext context) {
    return SidebarContainer(
      title: "搜索",
      child: TextField(
        onChanged: (val) {
          searchText = val;
        },
        onEditingComplete: () {
          Get.toNamed(Routes.search, parameters: {
            "keyword": searchText,
          });
        },
        decoration: InputDecoration(
          hintText: "输入标题",
          suffixIcon: Padding(
            padding: const EdgeInsets.all(kDefaultPadding / 2),
            child: SvgPicture.asset("assets/icons/feather_search.svg"),
          ),
          border: OutlineInputBorder(
            borderRadius: BorderRadius.all(
              Radius.circular(kDefaultPadding / 2),
            ),
            borderSide: BorderSide(color: Color(0xFFCCCCCC)),
          ),
        ),
      ),
    );
  }

}
